Optimal. Leaf size=88 \[ -\frac {\left (a^2-b^2\right ) x}{\left (a^2+b^2\right )^2}-\frac {2 a b \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac {a^2}{b \left (a^2+b^2\right ) d (a+b \tan (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.08, antiderivative size = 88, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 3, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3623, 3612,
3611} \begin {gather*} -\frac {a^2}{b d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac {2 a b \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^2}-\frac {x \left (a^2-b^2\right )}{\left (a^2+b^2\right )^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 3611
Rule 3612
Rule 3623
Rubi steps
\begin {align*} \int \frac {\tan ^2(c+d x)}{(a+b \tan (c+d x))^2} \, dx &=-\frac {a^2}{b \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac {\int \frac {-a+b \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{a^2+b^2}\\ &=-\frac {\left (a^2-b^2\right ) x}{\left (a^2+b^2\right )^2}-\frac {a^2}{b \left (a^2+b^2\right ) d (a+b \tan (c+d x))}-\frac {(2 a b) \int \frac {b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{\left (a^2+b^2\right )^2}\\ &=-\frac {\left (a^2-b^2\right ) x}{\left (a^2+b^2\right )^2}-\frac {2 a b \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac {a^2}{b \left (a^2+b^2\right ) d (a+b \tan (c+d x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 0.73, size = 161, normalized size = 1.83 \begin {gather*} \frac {-a \left ((a+i b)^2 (c+d x)+a b \log \left ((a \cos (c+d x)+b \sin (c+d x))^2\right )\right )+\left ((a+i b) \left (a^2-i b^2 (c+d x)-a b (i+c+d x)\right )-a b^2 \log \left ((a \cos (c+d x)+b \sin (c+d x))^2\right )\right ) \tan (c+d x)+2 i a b \text {ArcTan}(\tan (c+d x)) (a+b \tan (c+d x))}{\left (a^2+b^2\right )^2 d (a+b \tan (c+d x))} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.12, size = 101, normalized size = 1.15
method | result | size |
derivativedivides | \(\frac {\frac {a b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )+\left (-a^{2}+b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {a^{2}}{\left (a^{2}+b^{2}\right ) b \left (a +b \tan \left (d x +c \right )\right )}-\frac {2 a b \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{d}\) | \(101\) |
default | \(\frac {\frac {a b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )+\left (-a^{2}+b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {a^{2}}{\left (a^{2}+b^{2}\right ) b \left (a +b \tan \left (d x +c \right )\right )}-\frac {2 a b \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{d}\) | \(101\) |
norman | \(\frac {-\frac {a^{2}}{b d \left (a^{2}+b^{2}\right )}-\frac {\left (a^{2}-b^{2}\right ) a x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {b \left (a^{2}-b^{2}\right ) x \tan \left (d x +c \right )}{a^{4}+2 a^{2} b^{2}+b^{4}}}{a +b \tan \left (d x +c \right )}+\frac {a b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 a b \ln \left (a +b \tan \left (d x +c \right )\right )}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}\) | \(171\) |
risch | \(\frac {x}{2 i a b -a^{2}+b^{2}}+\frac {4 i a b x}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {4 i a b c}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 i a^{2}}{\left (i b +a \right ) d \left (-i b +a \right )^{2} \left (-i b \,{\mathrm e}^{2 i \left (d x +c \right )}+a \,{\mathrm e}^{2 i \left (d x +c \right )}+i b +a \right )}-\frac {2 a b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right )}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}\) | \(179\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 1.01, size = 137, normalized size = 1.56 \begin {gather*} -\frac {\frac {2 \, a b \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {a b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {{\left (a^{2} - b^{2}\right )} {\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {a^{2}}{a^{3} b + a b^{3} + {\left (a^{2} b^{2} + b^{4}\right )} \tan \left (d x + c\right )}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.87, size = 153, normalized size = 1.74 \begin {gather*} -\frac {a^{2} b + {\left (a^{3} - a b^{2}\right )} d x + {\left (a b^{2} \tan \left (d x + c\right ) + a^{2} b\right )} \log \left (\frac {b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) - {\left (a^{3} - {\left (a^{2} b - b^{3}\right )} d x\right )} \tan \left (d x + c\right )}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} d \tan \left (d x + c\right ) + {\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [C] Result contains complex when optimal does not.
time = 0.79, size = 1314, normalized size = 14.93 \begin {gather*} \begin {cases} \tilde {\infty } x & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {- x + \frac {\tan {\left (c + d x \right )}}{d}}{a^{2}} & \text {for}\: b = 0 \\\frac {d x \tan ^{2}{\left (c + d x \right )}}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} - 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} - \frac {2 i d x \tan {\left (c + d x \right )}}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} - 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} - \frac {d x}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} - 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} - \frac {3 \tan {\left (c + d x \right )}}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} - 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} + \frac {2 i}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} - 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} & \text {for}\: a = - i b \\\frac {d x \tan ^{2}{\left (c + d x \right )}}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} + 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} + \frac {2 i d x \tan {\left (c + d x \right )}}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} + 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} - \frac {d x}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} + 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} - \frac {3 \tan {\left (c + d x \right )}}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} + 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} - \frac {2 i}{4 b^{2} d \tan ^{2}{\left (c + d x \right )} + 8 i b^{2} d \tan {\left (c + d x \right )} - 4 b^{2} d} & \text {for}\: a = i b \\\frac {x \tan ^{2}{\left (c \right )}}{\left (a + b \tan {\left (c \right )}\right )^{2}} & \text {for}\: d = 0 \\- \frac {a^{4}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} - \frac {a^{3} b d x}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} - \frac {a^{2} b^{2} d x \tan {\left (c + d x \right )}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} - \frac {2 a^{2} b^{2} \log {\left (\frac {a}{b} + \tan {\left (c + d x \right )} \right )}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} + \frac {a^{2} b^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} - \frac {a^{2} b^{2}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} + \frac {a b^{3} d x}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} - \frac {2 a b^{3} \log {\left (\frac {a}{b} + \tan {\left (c + d x \right )} \right )} \tan {\left (c + d x \right )}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} + \frac {a b^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )} \tan {\left (c + d x \right )}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} + \frac {b^{4} d x \tan {\left (c + d x \right )}}{a^{5} b d + a^{4} b^{2} d \tan {\left (c + d x \right )} + 2 a^{3} b^{3} d + 2 a^{2} b^{4} d \tan {\left (c + d x \right )} + a b^{5} d + b^{6} d \tan {\left (c + d x \right )}} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.73, size = 165, normalized size = 1.88 \begin {gather*} -\frac {\frac {2 \, a b^{2} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b + 2 \, a^{2} b^{3} + b^{5}} - \frac {a b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {{\left (a^{2} - b^{2}\right )} {\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {2 \, a b^{3} \tan \left (d x + c\right ) - a^{4} + a^{2} b^{2}}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} {\left (b \tan \left (d x + c\right ) + a\right )}}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 4.07, size = 126, normalized size = 1.43 \begin {gather*} \frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )}{2\,d\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )}-\frac {a^2}{b\,d\,\left (a^2+b^2\right )\,\left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}-\frac {2\,a\,b\,\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}{d\,{\left (a^2+b^2\right )}^2}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,1{}\mathrm {i}}{2\,d\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________